Option Strict On
Option Explicit On 

Public Class FormView
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents miFile As System.Windows.Forms.MenuItem
    Friend WithEvents miFileClose As System.Windows.Forms.MenuItem
    Friend WithEvents miFileBar1 As System.Windows.Forms.MenuItem
    Friend WithEvents miFileSaveAs As System.Windows.Forms.MenuItem
    Friend WithEvents miFileBar2 As System.Windows.Forms.MenuItem
    Friend WithEvents miView As System.Windows.Forms.MenuItem
    Friend WithEvents miViewFilter As System.Windows.Forms.MenuItem
    Friend WithEvents miViewSort As System.Windows.Forms.MenuItem
    Friend WithEvents miViewCustom As System.Windows.Forms.MenuItem
    Friend WithEvents miViewRefresh As System.Windows.Forms.MenuItem
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
    Friend WithEvents Grid1 As Avand.Grid
    Friend WithEvents miFilePrintPreview As System.Windows.Forms.MenuItem
    Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
    Friend WithEvents tbPrint As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSep1 As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSep2 As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbRefresh As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSep3 As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbFilter As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSort As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSep4 As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbLookup As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbDrilldown As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbBack As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSep5 As System.Windows.Forms.ToolBarButton
    Friend WithEvents miFileBar3 As System.Windows.Forms.MenuItem
    Friend WithEvents miFilePrint As System.Windows.Forms.MenuItem
    Friend WithEvents tbPrintPreview As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSave As System.Windows.Forms.ToolBarButton
    Friend WithEvents miViewRecords As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsFirst As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsPrevious As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsNext As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsLast As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsBar1 As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsNew As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsGoTo As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsBar2 As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsEdit As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsUpdate As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsCancel As System.Windows.Forms.MenuItem
    Friend WithEvents miRecordsDelete As System.Windows.Forms.MenuItem
    Friend WithEvents miFileSave As System.Windows.Forms.MenuItem
    Friend WithEvents miLookupEmpty As System.Windows.Forms.MenuItem
    Friend WithEvents miDrilldownEmpty As System.Windows.Forms.MenuItem
    Friend WithEvents tbSep6 As System.Windows.Forms.ToolBarButton
    Friend WithEvents miFileDatasheetView As System.Windows.Forms.MenuItem
    Friend WithEvents tbDatasheetView As System.Windows.Forms.ToolBarButton
    Friend WithEvents miViewBack As System.Windows.Forms.MenuItem
    Friend WithEvents miViewLookup As System.Windows.Forms.MenuItem
    Friend WithEvents ContextMenu2 As System.Windows.Forms.ContextMenu
    Friend WithEvents ContextMenu3 As System.Windows.Forms.ContextMenu
    Friend WithEvents ciLookupEmpty As System.Windows.Forms.MenuItem
    Friend WithEvents ciDrilldownEmpty As System.Windows.Forms.MenuItem
    Friend WithEvents ToolBar2 As System.Windows.Forms.ToolBar
    Friend WithEvents tbFirst As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbPrevious As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBar3 As System.Windows.Forms.ToolBar
    Friend WithEvents tbNext As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbLast As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbSep7 As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbNew As System.Windows.Forms.ToolBarButton
    Friend WithEvents tbDelete As System.Windows.Forms.ToolBarButton
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents miViewSelect As System.Windows.Forms.MenuItem
    Friend WithEvents miViewBar1 As System.Windows.Forms.MenuItem
    Friend WithEvents miViewBar2 As System.Windows.Forms.MenuItem
    Friend WithEvents miViewBar3 As System.Windows.Forms.MenuItem
    Friend WithEvents miViewBar4 As System.Windows.Forms.MenuItem
    Friend WithEvents miViewBar5 As System.Windows.Forms.MenuItem
    Friend WithEvents lblCount As System.Windows.Forms.Label
    Friend WithEvents updNumber As System.Windows.Forms.NumericUpDown
    Friend WithEvents lblRow As System.Windows.Forms.Label
    Friend WithEvents miViewDrilldown As System.Windows.Forms.MenuItem
    Friend WithEvents ImageList2 As System.Windows.Forms.ImageList
    Friend WithEvents miComputesEmpty As System.Windows.Forms.MenuItem
    Friend WithEvents tbComputes As System.Windows.Forms.ToolBarButton
    Friend WithEvents ContextMenu4 As System.Windows.Forms.ContextMenu
    Friend WithEvents ciComputesEmpty As System.Windows.Forms.MenuItem
    Friend WithEvents miViewComputes As System.Windows.Forms.MenuItem
    Friend WithEvents btnOk As System.Windows.Forms.Button
    Friend WithEvents Navigator1 As Avand.Navigator
    Friend WithEvents Splitter1 As System.Windows.Forms.Splitter
    Friend WithEvents miEditCopy As System.Windows.Forms.MenuItem
    Friend WithEvents miEditPaste As System.Windows.Forms.MenuItem
    Friend WithEvents miEditCut As System.Windows.Forms.MenuItem
    Friend WithEvents miEdit As System.Windows.Forms.MenuItem
    Friend WithEvents miEditBar1 As System.Windows.Forms.MenuItem
    Friend WithEvents miEditSelectAll As System.Windows.Forms.MenuItem
    Friend WithEvents miViewSimpleFilter As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(FormView))
        Me.MainMenu1 = New System.Windows.Forms.MainMenu(Me.components)
        Me.miFile = New System.Windows.Forms.MenuItem()
        Me.miFileClose = New System.Windows.Forms.MenuItem()
        Me.miFileBar1 = New System.Windows.Forms.MenuItem()
        Me.miFileSave = New System.Windows.Forms.MenuItem()
        Me.miFileSaveAs = New System.Windows.Forms.MenuItem()
        Me.miFileBar2 = New System.Windows.Forms.MenuItem()
        Me.miFilePrint = New System.Windows.Forms.MenuItem()
        Me.miFilePrintPreview = New System.Windows.Forms.MenuItem()
        Me.miFileBar3 = New System.Windows.Forms.MenuItem()
        Me.miFileDatasheetView = New System.Windows.Forms.MenuItem()
        Me.miEdit = New System.Windows.Forms.MenuItem()
        Me.miEditCut = New System.Windows.Forms.MenuItem()
        Me.miEditCopy = New System.Windows.Forms.MenuItem()
        Me.miEditPaste = New System.Windows.Forms.MenuItem()
        Me.miEditBar1 = New System.Windows.Forms.MenuItem()
        Me.miEditSelectAll = New System.Windows.Forms.MenuItem()
        Me.miView = New System.Windows.Forms.MenuItem()
        Me.miViewSelect = New System.Windows.Forms.MenuItem()
        Me.miViewBar1 = New System.Windows.Forms.MenuItem()
        Me.miViewRecords = New System.Windows.Forms.MenuItem()
        Me.miRecordsFirst = New System.Windows.Forms.MenuItem()
        Me.miRecordsPrevious = New System.Windows.Forms.MenuItem()
        Me.miRecordsNext = New System.Windows.Forms.MenuItem()
        Me.miRecordsLast = New System.Windows.Forms.MenuItem()
        Me.miRecordsBar1 = New System.Windows.Forms.MenuItem()
        Me.miRecordsGoTo = New System.Windows.Forms.MenuItem()
        Me.miRecordsNew = New System.Windows.Forms.MenuItem()
        Me.miRecordsBar2 = New System.Windows.Forms.MenuItem()
        Me.miRecordsEdit = New System.Windows.Forms.MenuItem()
        Me.miRecordsUpdate = New System.Windows.Forms.MenuItem()
        Me.miRecordsCancel = New System.Windows.Forms.MenuItem()
        Me.miRecordsDelete = New System.Windows.Forms.MenuItem()
        Me.miViewComputes = New System.Windows.Forms.MenuItem()
        Me.miComputesEmpty = New System.Windows.Forms.MenuItem()
        Me.miViewBack = New System.Windows.Forms.MenuItem()
        Me.miViewBar2 = New System.Windows.Forms.MenuItem()
        Me.miViewLookup = New System.Windows.Forms.MenuItem()
        Me.miLookupEmpty = New System.Windows.Forms.MenuItem()
        Me.miViewDrilldown = New System.Windows.Forms.MenuItem()
        Me.miDrilldownEmpty = New System.Windows.Forms.MenuItem()
        Me.miViewBar3 = New System.Windows.Forms.MenuItem()
        Me.miViewFilter = New System.Windows.Forms.MenuItem()
        Me.miViewSort = New System.Windows.Forms.MenuItem()
        Me.miViewSimpleFilter = New System.Windows.Forms.MenuItem()
        Me.miViewBar4 = New System.Windows.Forms.MenuItem()
        Me.miViewCustom = New System.Windows.Forms.MenuItem()
        Me.miViewBar5 = New System.Windows.Forms.MenuItem()
        Me.miViewRefresh = New System.Windows.Forms.MenuItem()
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.ContextMenu1 = New System.Windows.Forms.ContextMenu()
        Me.Grid1 = New Avand.Grid()
        Me.ToolBar1 = New System.Windows.Forms.ToolBar()
        Me.tbPrint = New System.Windows.Forms.ToolBarButton()
        Me.tbPrintPreview = New System.Windows.Forms.ToolBarButton()
        Me.tbSep1 = New System.Windows.Forms.ToolBarButton()
        Me.tbDatasheetView = New System.Windows.Forms.ToolBarButton()
        Me.tbSep2 = New System.Windows.Forms.ToolBarButton()
        Me.tbSave = New System.Windows.Forms.ToolBarButton()
        Me.tbSep3 = New System.Windows.Forms.ToolBarButton()
        Me.tbRefresh = New System.Windows.Forms.ToolBarButton()
        Me.tbSep4 = New System.Windows.Forms.ToolBarButton()
        Me.tbFilter = New System.Windows.Forms.ToolBarButton()
        Me.tbSort = New System.Windows.Forms.ToolBarButton()
        Me.tbSep5 = New System.Windows.Forms.ToolBarButton()
        Me.tbComputes = New System.Windows.Forms.ToolBarButton()
        Me.ContextMenu4 = New System.Windows.Forms.ContextMenu()
        Me.ciComputesEmpty = New System.Windows.Forms.MenuItem()
        Me.tbBack = New System.Windows.Forms.ToolBarButton()
        Me.tbSep6 = New System.Windows.Forms.ToolBarButton()
        Me.tbLookup = New System.Windows.Forms.ToolBarButton()
        Me.ContextMenu2 = New System.Windows.Forms.ContextMenu()
        Me.ciLookupEmpty = New System.Windows.Forms.MenuItem()
        Me.tbDrilldown = New System.Windows.Forms.ToolBarButton()
        Me.ContextMenu3 = New System.Windows.Forms.ContextMenu()
        Me.ciDrilldownEmpty = New System.Windows.Forms.MenuItem()
        Me.lblCount = New System.Windows.Forms.Label()
        Me.ToolBar2 = New System.Windows.Forms.ToolBar()
        Me.tbFirst = New System.Windows.Forms.ToolBarButton()
        Me.tbPrevious = New System.Windows.Forms.ToolBarButton()
        Me.ToolBar3 = New System.Windows.Forms.ToolBar()
        Me.tbNext = New System.Windows.Forms.ToolBarButton()
        Me.tbLast = New System.Windows.Forms.ToolBarButton()
        Me.tbSep7 = New System.Windows.Forms.ToolBarButton()
        Me.tbNew = New System.Windows.Forms.ToolBarButton()
        Me.tbDelete = New System.Windows.Forms.ToolBarButton()
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.btnOk = New System.Windows.Forms.Button()
        Me.lblRow = New System.Windows.Forms.Label()
        Me.updNumber = New System.Windows.Forms.NumericUpDown()
        Me.ImageList2 = New System.Windows.Forms.ImageList(Me.components)
        Me.Navigator1 = New Avand.Navigator()
        Me.Splitter1 = New System.Windows.Forms.Splitter()
        Me.Panel1.SuspendLayout()
        CType(Me.updNumber, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miFile, Me.miEdit, Me.miView})
        '
        'miFile
        '
        Me.miFile.Index = 0
        Me.miFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miFileClose, Me.miFileBar1, Me.miFileSave, Me.miFileSaveAs, Me.miFileBar2, Me.miFilePrint, Me.miFilePrintPreview, Me.miFileBar3, Me.miFileDatasheetView})
        Me.miFile.MergeOrder = 1
        Me.miFile.MergeType = System.Windows.Forms.MenuMerge.MergeItems
        resources.ApplyResources(Me.miFile, "miFile")
        '
        'miFileClose
        '
        Me.miFileClose.Index = 0
        Me.miFileClose.MergeOrder = 2
        resources.ApplyResources(Me.miFileClose, "miFileClose")
        '
        'miFileBar1
        '
        Me.miFileBar1.Index = 1
        Me.miFileBar1.MergeOrder = 3
        resources.ApplyResources(Me.miFileBar1, "miFileBar1")
        '
        'miFileSave
        '
        Me.miFileSave.Index = 2
        Me.miFileSave.MergeOrder = 4
        resources.ApplyResources(Me.miFileSave, "miFileSave")
        '
        'miFileSaveAs
        '
        resources.ApplyResources(Me.miFileSaveAs, "miFileSaveAs")
        Me.miFileSaveAs.Index = 3
        Me.miFileSaveAs.MergeOrder = 5
        '
        'miFileBar2
        '
        Me.miFileBar2.Index = 4
        Me.miFileBar2.MergeOrder = 6
        resources.ApplyResources(Me.miFileBar2, "miFileBar2")
        '
        'miFilePrint
        '
        Me.miFilePrint.Index = 5
        Me.miFilePrint.MergeOrder = 7
        resources.ApplyResources(Me.miFilePrint, "miFilePrint")
        '
        'miFilePrintPreview
        '
        Me.miFilePrintPreview.Index = 6
        Me.miFilePrintPreview.MergeOrder = 9
        resources.ApplyResources(Me.miFilePrintPreview, "miFilePrintPreview")
        '
        'miFileBar3
        '
        Me.miFileBar3.Index = 7
        Me.miFileBar3.MergeOrder = 8
        resources.ApplyResources(Me.miFileBar3, "miFileBar3")
        '
        'miFileDatasheetView
        '
        resources.ApplyResources(Me.miFileDatasheetView, "miFileDatasheetView")
        Me.miFileDatasheetView.Index = 8
        Me.miFileDatasheetView.MergeOrder = 10
        '
        'miEdit
        '
        Me.miEdit.Index = 1
        Me.miEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miEditCut, Me.miEditCopy, Me.miEditPaste, Me.miEditBar1, Me.miEditSelectAll})
        Me.miEdit.MergeOrder = 2
        Me.miEdit.MergeType = System.Windows.Forms.MenuMerge.MergeItems
        resources.ApplyResources(Me.miEdit, "miEdit")
        '
        'miEditCut
        '
        Me.miEditCut.Index = 0
        resources.ApplyResources(Me.miEditCut, "miEditCut")
        '
        'miEditCopy
        '
        Me.miEditCopy.Index = 1
        resources.ApplyResources(Me.miEditCopy, "miEditCopy")
        '
        'miEditPaste
        '
        Me.miEditPaste.Index = 2
        resources.ApplyResources(Me.miEditPaste, "miEditPaste")
        '
        'miEditBar1
        '
        Me.miEditBar1.Index = 3
        resources.ApplyResources(Me.miEditBar1, "miEditBar1")
        '
        'miEditSelectAll
        '
        Me.miEditSelectAll.Index = 4
        resources.ApplyResources(Me.miEditSelectAll, "miEditSelectAll")
        '
        'miView
        '
        Me.miView.Index = 2
        Me.miView.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miViewSelect, Me.miViewBar1, Me.miViewRecords, Me.miViewComputes, Me.miViewBack, Me.miViewBar2, Me.miViewLookup, Me.miViewDrilldown, Me.miViewBar3, Me.miViewFilter, Me.miViewSort, Me.miViewSimpleFilter, Me.miViewBar4, Me.miViewCustom, Me.miViewBar5, Me.miViewRefresh})
        Me.miView.MergeOrder = 3
        Me.miView.MergeType = System.Windows.Forms.MenuMerge.MergeItems
        resources.ApplyResources(Me.miView, "miView")
        '
        'miViewSelect
        '
        Me.miViewSelect.DefaultItem = True
        Me.miViewSelect.Index = 0
        resources.ApplyResources(Me.miViewSelect, "miViewSelect")
        '
        'miViewBar1
        '
        Me.miViewBar1.Index = 1
        resources.ApplyResources(Me.miViewBar1, "miViewBar1")
        '
        'miViewRecords
        '
        Me.miViewRecords.Index = 2
        Me.miViewRecords.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miRecordsFirst, Me.miRecordsPrevious, Me.miRecordsNext, Me.miRecordsLast, Me.miRecordsBar1, Me.miRecordsGoTo, Me.miRecordsNew, Me.miRecordsBar2, Me.miRecordsEdit, Me.miRecordsUpdate, Me.miRecordsCancel, Me.miRecordsDelete})
        resources.ApplyResources(Me.miViewRecords, "miViewRecords")
        '
        'miRecordsFirst
        '
        Me.miRecordsFirst.Index = 0
        resources.ApplyResources(Me.miRecordsFirst, "miRecordsFirst")
        '
        'miRecordsPrevious
        '
        Me.miRecordsPrevious.Index = 1
        resources.ApplyResources(Me.miRecordsPrevious, "miRecordsPrevious")
        '
        'miRecordsNext
        '
        Me.miRecordsNext.Index = 2
        resources.ApplyResources(Me.miRecordsNext, "miRecordsNext")
        '
        'miRecordsLast
        '
        Me.miRecordsLast.Index = 3
        resources.ApplyResources(Me.miRecordsLast, "miRecordsLast")
        '
        'miRecordsBar1
        '
        Me.miRecordsBar1.Index = 4
        resources.ApplyResources(Me.miRecordsBar1, "miRecordsBar1")
        '
        'miRecordsGoTo
        '
        Me.miRecordsGoTo.Index = 5
        resources.ApplyResources(Me.miRecordsGoTo, "miRecordsGoTo")
        '
        'miRecordsNew
        '
        Me.miRecordsNew.Index = 6
        resources.ApplyResources(Me.miRecordsNew, "miRecordsNew")
        '
        'miRecordsBar2
        '
        Me.miRecordsBar2.Index = 7
        resources.ApplyResources(Me.miRecordsBar2, "miRecordsBar2")
        '
        'miRecordsEdit
        '
        Me.miRecordsEdit.Index = 8
        resources.ApplyResources(Me.miRecordsEdit, "miRecordsEdit")
        '
        'miRecordsUpdate
        '
        Me.miRecordsUpdate.Index = 9
        resources.ApplyResources(Me.miRecordsUpdate, "miRecordsUpdate")
        '
        'miRecordsCancel
        '
        Me.miRecordsCancel.Index = 10
        resources.ApplyResources(Me.miRecordsCancel, "miRecordsCancel")
        '
        'miRecordsDelete
        '
        Me.miRecordsDelete.Index = 11
        resources.ApplyResources(Me.miRecordsDelete, "miRecordsDelete")
        '
        'miViewComputes
        '
        Me.miViewComputes.Index = 3
        Me.miViewComputes.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miComputesEmpty})
        resources.ApplyResources(Me.miViewComputes, "miViewComputes")
        '
        'miComputesEmpty
        '
        resources.ApplyResources(Me.miComputesEmpty, "miComputesEmpty")
        Me.miComputesEmpty.Index = 0
        '
        'miViewBack
        '
        Me.miViewBack.Index = 4
        resources.ApplyResources(Me.miViewBack, "miViewBack")
        '
        'miViewBar2
        '
        Me.miViewBar2.Index = 5
        resources.ApplyResources(Me.miViewBar2, "miViewBar2")
        '
        'miViewLookup
        '
        Me.miViewLookup.Index = 6
        Me.miViewLookup.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miLookupEmpty})
        resources.ApplyResources(Me.miViewLookup, "miViewLookup")
        '
        'miLookupEmpty
        '
        resources.ApplyResources(Me.miLookupEmpty, "miLookupEmpty")
        Me.miLookupEmpty.Index = 0
        '
        'miViewDrilldown
        '
        Me.miViewDrilldown.Index = 7
        Me.miViewDrilldown.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.miDrilldownEmpty})
        resources.ApplyResources(Me.miViewDrilldown, "miViewDrilldown")
        '
        'miDrilldownEmpty
        '
        resources.ApplyResources(Me.miDrilldownEmpty, "miDrilldownEmpty")
        Me.miDrilldownEmpty.Index = 0
        '
        'miViewBar3
        '
        Me.miViewBar3.Index = 8
        resources.ApplyResources(Me.miViewBar3, "miViewBar3")
        '
        'miViewFilter
        '
        Me.miViewFilter.Index = 9
        resources.ApplyResources(Me.miViewFilter, "miViewFilter")
        '
        'miViewSort
        '
        Me.miViewSort.Index = 10
        resources.ApplyResources(Me.miViewSort, "miViewSort")
        '
        'miViewSimpleFilter
        '
        Me.miViewSimpleFilter.Index = 11
        resources.ApplyResources(Me.miViewSimpleFilter, "miViewSimpleFilter")
        '
        'miViewBar4
        '
        Me.miViewBar4.Index = 12
        resources.ApplyResources(Me.miViewBar4, "miViewBar4")
        '
        'miViewCustom
        '
        Me.miViewCustom.Index = 13
        resources.ApplyResources(Me.miViewCustom, "miViewCustom")
        '
        'miViewBar5
        '
        Me.miViewBar5.Index = 14
        resources.ApplyResources(Me.miViewBar5, "miViewBar5")
        '
        'miViewRefresh
        '
        Me.miViewRefresh.Index = 15
        resources.ApplyResources(Me.miViewRefresh, "miViewRefresh")
        '
        'ImageList1
        '
        Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        Me.ImageList1.Images.SetKeyName(0, "")
        Me.ImageList1.Images.SetKeyName(1, "")
        Me.ImageList1.Images.SetKeyName(2, "")
        Me.ImageList1.Images.SetKeyName(3, "")
        Me.ImageList1.Images.SetKeyName(4, "")
        Me.ImageList1.Images.SetKeyName(5, "")
        Me.ImageList1.Images.SetKeyName(6, "")
        Me.ImageList1.Images.SetKeyName(7, "")
        Me.ImageList1.Images.SetKeyName(8, "")
        Me.ImageList1.Images.SetKeyName(9, "")
        Me.ImageList1.Images.SetKeyName(10, "")
        Me.ImageList1.Images.SetKeyName(11, "")
        Me.ImageList1.Images.SetKeyName(12, "")
        Me.ImageList1.Images.SetKeyName(13, "")
        Me.ImageList1.Images.SetKeyName(14, "")
        Me.ImageList1.Images.SetKeyName(15, "")
        Me.ImageList1.Images.SetKeyName(16, "")
        '
        'ContextMenu1
        '
        '
        'Grid1
        '
        Me.Grid1.BackColor = System.Drawing.SystemColors.AppWorkspace
        Me.Grid1.Connections = Nothing
        Me.Grid1.ContextMenu = Me.ContextMenu1
        Me.Grid1.Current = Nothing
        Me.Grid1.DataRowIndex = 0
        resources.ApplyResources(Me.Grid1, "Grid1")
        Me.Grid1.Layouting = Nothing
        Me.Grid1.MemberName = Nothing
        Me.Grid1.MultiSelect = Nothing
        Me.Grid1.Name = "Grid1"
        Me.Grid1.OleDbConnection = Nothing
        Me.Grid1.ParentFormView = Nothing
        Me.Grid1.PersistRow = Nothing
        Me.Grid1.Relation = Nothing
        Me.Grid1.TextMode = False
        Me.Grid1.User = Nothing
        '
        'ToolBar1
        '
        resources.ApplyResources(Me.ToolBar1, "ToolBar1")
        Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbPrint, Me.tbPrintPreview, Me.tbSep1, Me.tbDatasheetView, Me.tbSep2, Me.tbSave, Me.tbSep3, Me.tbRefresh, Me.tbSep4, Me.tbFilter, Me.tbSort, Me.tbSep5, Me.tbComputes, Me.tbBack, Me.tbSep6, Me.tbLookup, Me.tbDrilldown})
        Me.ToolBar1.ImageList = Me.ImageList1
        Me.ToolBar1.Name = "ToolBar1"
        '
        'tbPrint
        '
        resources.ApplyResources(Me.tbPrint, "tbPrint")
        Me.tbPrint.Name = "tbPrint"
        '
        'tbPrintPreview
        '
        resources.ApplyResources(Me.tbPrintPreview, "tbPrintPreview")
        Me.tbPrintPreview.Name = "tbPrintPreview"
        '
        'tbSep1
        '
        Me.tbSep1.Name = "tbSep1"
        Me.tbSep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbDatasheetView
        '
        resources.ApplyResources(Me.tbDatasheetView, "tbDatasheetView")
        Me.tbDatasheetView.Name = "tbDatasheetView"
        '
        'tbSep2
        '
        Me.tbSep2.Name = "tbSep2"
        Me.tbSep2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbSave
        '
        resources.ApplyResources(Me.tbSave, "tbSave")
        Me.tbSave.Name = "tbSave"
        '
        'tbSep3
        '
        Me.tbSep3.Name = "tbSep3"
        Me.tbSep3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbRefresh
        '
        resources.ApplyResources(Me.tbRefresh, "tbRefresh")
        Me.tbRefresh.Name = "tbRefresh"
        '
        'tbSep4
        '
        Me.tbSep4.Name = "tbSep4"
        Me.tbSep4.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbFilter
        '
        resources.ApplyResources(Me.tbFilter, "tbFilter")
        Me.tbFilter.Name = "tbFilter"
        '
        'tbSort
        '
        resources.ApplyResources(Me.tbSort, "tbSort")
        Me.tbSort.Name = "tbSort"
        '
        'tbSep5
        '
        Me.tbSep5.Name = "tbSep5"
        Me.tbSep5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbComputes
        '
        Me.tbComputes.DropDownMenu = Me.ContextMenu4
        resources.ApplyResources(Me.tbComputes, "tbComputes")
        Me.tbComputes.Name = "tbComputes"
        Me.tbComputes.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton
        '
        'ContextMenu4
        '
        Me.ContextMenu4.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ciComputesEmpty})
        '
        'ciComputesEmpty
        '
        resources.ApplyResources(Me.ciComputesEmpty, "ciComputesEmpty")
        Me.ciComputesEmpty.Index = 0
        '
        'tbBack
        '
        resources.ApplyResources(Me.tbBack, "tbBack")
        Me.tbBack.Name = "tbBack"
        '
        'tbSep6
        '
        Me.tbSep6.Name = "tbSep6"
        Me.tbSep6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbLookup
        '
        Me.tbLookup.DropDownMenu = Me.ContextMenu2
        resources.ApplyResources(Me.tbLookup, "tbLookup")
        Me.tbLookup.Name = "tbLookup"
        Me.tbLookup.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton
        '
        'ContextMenu2
        '
        Me.ContextMenu2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ciLookupEmpty})
        '
        'ciLookupEmpty
        '
        resources.ApplyResources(Me.ciLookupEmpty, "ciLookupEmpty")
        Me.ciLookupEmpty.Index = 0
        '
        'tbDrilldown
        '
        Me.tbDrilldown.DropDownMenu = Me.ContextMenu3
        resources.ApplyResources(Me.tbDrilldown, "tbDrilldown")
        Me.tbDrilldown.Name = "tbDrilldown"
        Me.tbDrilldown.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton
        '
        'ContextMenu3
        '
        Me.ContextMenu3.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.ciDrilldownEmpty})
        '
        'ciDrilldownEmpty
        '
        resources.ApplyResources(Me.ciDrilldownEmpty, "ciDrilldownEmpty")
        Me.ciDrilldownEmpty.Index = 0
        '
        'lblCount
        '
        resources.ApplyResources(Me.lblCount, "lblCount")
        Me.lblCount.Name = "lblCount"
        '
        'ToolBar2
        '
        resources.ApplyResources(Me.ToolBar2, "ToolBar2")
        Me.ToolBar2.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbFirst, Me.tbPrevious})
        Me.ToolBar2.Divider = False
        Me.ToolBar2.ImageList = Me.ImageList1
        Me.ToolBar2.Name = "ToolBar2"
        '
        'tbFirst
        '
        resources.ApplyResources(Me.tbFirst, "tbFirst")
        Me.tbFirst.Name = "tbFirst"
        '
        'tbPrevious
        '
        resources.ApplyResources(Me.tbPrevious, "tbPrevious")
        Me.tbPrevious.Name = "tbPrevious"
        '
        'ToolBar3
        '
        resources.ApplyResources(Me.ToolBar3, "ToolBar3")
        Me.ToolBar3.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbNext, Me.tbLast, Me.tbSep7, Me.tbNew, Me.tbDelete})
        Me.ToolBar3.Divider = False
        Me.ToolBar3.ImageList = Me.ImageList1
        Me.ToolBar3.Name = "ToolBar3"
        '
        'tbNext
        '
        resources.ApplyResources(Me.tbNext, "tbNext")
        Me.tbNext.Name = "tbNext"
        '
        'tbLast
        '
        resources.ApplyResources(Me.tbLast, "tbLast")
        Me.tbLast.Name = "tbLast"
        '
        'tbSep7
        '
        Me.tbSep7.Name = "tbSep7"
        Me.tbSep7.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
        '
        'tbNew
        '
        resources.ApplyResources(Me.tbNew, "tbNew")
        Me.tbNew.Name = "tbNew"
        '
        'tbDelete
        '
        resources.ApplyResources(Me.tbDelete, "tbDelete")
        Me.tbDelete.Name = "tbDelete"
        '
        'Panel1
        '
        Me.Panel1.Controls.Add(Me.btnOk)
        Me.Panel1.Controls.Add(Me.lblRow)
        Me.Panel1.Controls.Add(Me.lblCount)
        Me.Panel1.Controls.Add(Me.updNumber)
        Me.Panel1.Controls.Add(Me.ToolBar2)
        Me.Panel1.Controls.Add(Me.ToolBar3)
        resources.ApplyResources(Me.Panel1, "Panel1")
        Me.Panel1.Name = "Panel1"
        '
        'btnOk
        '
        resources.ApplyResources(Me.btnOk, "btnOk")
        Me.btnOk.Name = "btnOk"
        '
        'lblRow
        '
        resources.ApplyResources(Me.lblRow, "lblRow")
        Me.lblRow.Name = "lblRow"
        '
        'updNumber
        '
        resources.ApplyResources(Me.updNumber, "updNumber")
        Me.updNumber.Name = "updNumber"
        '
        'ImageList2
        '
        Me.ImageList2.ImageStream = CType(resources.GetObject("ImageList2.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList2.TransparentColor = System.Drawing.Color.Transparent
        Me.ImageList2.Images.SetKeyName(0, "")
        Me.ImageList2.Images.SetKeyName(1, "")
        '
        'Navigator1
        '
        Me.Navigator1.BackColor = System.Drawing.SystemColors.AppWorkspace
        Me.Navigator1.Chain = Nothing
        Me.Navigator1.Cursor = System.Windows.Forms.Cursors.Hand
        resources.ApplyResources(Me.Navigator1, "Navigator1")
        Me.Navigator1.Name = "Navigator1"
        Me.Navigator1.User = Nothing
        '
        'Splitter1
        '
        Me.Splitter1.BackColor = System.Drawing.Color.White
        resources.ApplyResources(Me.Splitter1, "Splitter1")
        Me.Splitter1.Name = "Splitter1"
        Me.Splitter1.TabStop = False
        '
        'FormView
        '
        resources.ApplyResources(Me, "$this")
        Me.Controls.Add(Me.Grid1)
        Me.Controls.Add(Me.Splitter1)
        Me.Controls.Add(Me.Navigator1)
        Me.Controls.Add(Me.ToolBar1)
        Me.Controls.Add(Me.Panel1)
        Me.KeyPreview = True
        Me.Menu = Me.MainMenu1
        Me.Name = "FormView"
        Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show
        Me.Panel1.ResumeLayout(False)
        Me.Panel1.PerformLayout()
        CType(Me.updNumber, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    'Private fConnectionList As Avand.ConnectionList
    Dim fFilter As Avand.Expression
    Dim fSort As Avand.Expression
    Dim [of] As String
    Dim rowChange, switch As Boolean

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        If Not Grid1.Updating() Then Exit Sub
        If Grid1.ParentFormView.Grid1.Current.RowData.Row.Table.Columns.Contains(Grid1.MultiSelect.DestinationField) Then
        Else
            Me.DialogResult = DialogResult.Cancel
            Exit Sub
        End If
        If Not Grid1.MultiSelect Is Nothing Then
            Dim isEdit As Boolean

            If Grid1.ParentFormView.Grid1.Current.RowData Is Nothing Then
                Grid1.ParentFormView.Grid1.Current.RowData = Grid1.ParentFormView.Grid1.Current.DataView.AddNew
            Else
                isEdit = Grid1.ParentFormView.Grid1.Current.RowData.IsEdit
                If Not Grid1.ParentFormView.Grid1.Current.RowData.IsEdit Then Grid1.ParentFormView.Grid1.Current.RowData.BeginEdit()
            End If

            Application.DoEvents()
            Cursor.Current = Cursors.WaitCursor
            '----------------------------------
            Try
                Dim str As String = ""
                Dim selCol, srcCol As DataColumn
                selCol = Grid1.MultiSelect.DataTable.DataTable.Columns(Grid1.MultiSelect.SelectionField)
                srcCol = Grid1.MultiSelect.DataTable.DataTable.Columns(Grid1.MultiSelect.SourceField)

                Dim row As DataRow
                For Each row In Grid1.MultiSelect.DataTable.DataTable.Rows
                    If CBool(row(selCol)) Then str &= CStr(row(srcCol)) & ", "
                Next : row = Nothing

                selCol = Nothing : srcCol = Nothing
                If str <> "" Then str = Mid(str, 1, str.Length - 2)
                Grid1.ParentFormView.Grid1.Current.RowData(Grid1.MultiSelect.DestinationField) = str
                Me.DialogResult = DialogResult.OK
            Catch ex As Exception
                MsgBox(ex.Message)
                If Not isEdit Then Grid1.ParentFormView.Grid1.Current.RowData.CancelEdit()
            End Try
            '----------------------------------
            Cursor.Current = Cursors.Default
        End If
    End Sub
    Private Sub ContextMenu1_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup
        EditMenu()

        ContextMenu1.MenuItems.Clear()
        ContextMenu1.MenuItems(ContextMenu1.MenuItems.Add(miEditCut.CloneMenu)).Shortcut = Shortcut.None
        ContextMenu1.MenuItems(ContextMenu1.MenuItems.Add(miEditCopy.CloneMenu)).Shortcut = Shortcut.None
        ContextMenu1.MenuItems(ContextMenu1.MenuItems.Add(miEditPaste.CloneMenu)).Shortcut = Shortcut.None
        ContextMenu1.MenuItems.Add("-")
        ContextMenu1.MenuItems(ContextMenu1.MenuItems.Add(miEditSelectAll.CloneMenu)).Shortcut = Shortcut.None
        ContextMenu1.MenuItems.Add("-")
        ContextMenu1.MenuItems.Add(miViewSelect.CloneMenu)
        ContextMenu1.MenuItems.Add(miViewBar1.CloneMenu)
        ContextMenu1.MenuItems.Add(miViewRecords.CloneMenu)
        ContextMenu1.MenuItems.Add(miViewBack.CloneMenu)
        ContextMenu1.MenuItems.Add(miViewBar2.CloneMenu)
        ContextMenu1.MenuItems.Add(miViewLookup.CloneMenu)
        ContextMenu1.MenuItems.Add(miViewDrilldown.CloneMenu)
    End Sub
    Private Sub miEdit_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles miEdit.Popup
        EditMenu()
    End Sub
    Private Sub Navigator1_RowSelect(ByVal sender As Object, ByVal e As Model10.RowEventArgs) Handles Navigator1.RowSelect
        Back(e.RowIndex)
    End Sub

    Private Sub FormView_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
        'Try
        '    If Not switch And Grid1.Relation Is Nothing Then Grid1.Current.Table.Presentation.CloseConnections()
        '    If Not fConnectionList Is Nothing Then fConnectionList.Close()
        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try
    End Sub
    Private Sub FormView_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        'If Not switch Then e.Cancel = Cancel()
    End Sub
    Private Sub FormView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Escape Then
            If Grid1.Current.DataView.Count > 0 And Grid1.DataRowIndex >= 0 Then
                If Grid1.DataRowIndex <= Grid1.Current.DataView.Count - 1 Then
                    If Grid1.Current.RowData.IsEdit Then
                        'Grid1.Canceling(dr)
                    Else
                        If Me.Modal Then Me.Close()
                    End If
                Else
                    If Me.Modal Then Me.Close()
                End If
            Else
                If Me.Modal Then Me.Close()
            End If
        End If
    End Sub
    Private Sub FormView_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
    End Sub
    Private Sub FormView_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        Select Case e.KeyCode
            Case Keys.F7
                If tbLookup.Visible Then
                    ContextMenu2.Show(ToolBar1, New Point(tbLookup.Rectangle.Left, tbLookup.Rectangle.Bottom))
                End If
            Case Keys.F8
                If tbDrilldown.Visible Then
                    ContextMenu3.Show(ToolBar1, New Point(tbDrilldown.Rectangle.Left, tbDrilldown.Rectangle.Bottom))
                End If
        End Select
    End Sub
    Private Sub FormView_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TinyErrorMessage()
        If Me.Modal Then
            'miFilePrintPreview.Visible = False
            miFileBar3.Visible = False
            miFileDatasheetView.Visible = False
            miViewSelect.Visible = True
            miViewBar1.Visible = True
            miViewBar4.Visible = False
            miViewCustom.Visible = False
            If Grid1.MultiSelect Is Nothing Then
                miViewBar5.Visible = False
                miViewRefresh.Visible = False
            End If
            '----------------------------------
            'tbPrintPreview.Visible = False
            tbSep1.Visible = False
            tbDatasheetView.Visible = False
            If Grid1.MultiSelect Is Nothing Then
                tbSep3.Visible = False
                tbRefresh.Visible = False
            End If
            '----------------------------------
            If Not Grid1.MultiSelect Is Nothing Then
                If Grid1.MultiSelect.SelectionField.Trim <> "" Then
                    btnOk.Visible = True
                End If
            End If
        End If
    End Sub

    Private Sub Grid1_RowChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowChange
    End Sub
    Private Sub Grid1_RowChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowChangeCommitted
        If Grid1.DataRowIndex = -1 Then
            miViewSelect.Enabled = False
            miRecordsFirst.Enabled = False : tbFirst.Enabled = False
            miRecordsPrevious.Enabled = False : tbPrevious.Enabled = False
            miRecordsNext.Enabled = False : tbNext.Enabled = False
            miRecordsLast.Enabled = False : tbLast.Enabled = False
            miRecordsGoTo.Enabled = False
            miRecordsNew.Enabled = False
            miRecordsDelete.Enabled = False : tbDelete.Enabled = False
            miViewLookup.Enabled = False : tbLookup.Enabled = False
            miViewDrilldown.Enabled = False : tbDrilldown.Enabled = False
            lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
        Else
            If Grid1.DataRowIndex = 0 Then
                miRecordsFirst.Enabled = False : tbFirst.Enabled = False
                miRecordsPrevious.Enabled = False : tbPrevious.Enabled = False
            Else
                miRecordsFirst.Enabled = True : tbFirst.Enabled = True
                miRecordsPrevious.Enabled = True : tbPrevious.Enabled = True
            End If
            If Grid1.DataRowIndex = Grid1.Current.DataView.Count - 1 Then
                miViewSelect.Enabled = True
                If Grid1.Current.Table.InsertCommand Is Nothing Then
                    miRecordsNext.Enabled = False : tbNext.Enabled = False
                Else
                    miRecordsNext.Enabled = True : tbNext.Enabled = True
                End If
                miRecordsLast.Enabled = False : tbLast.Enabled = False
                miRecordsGoTo.Enabled = True
                miRecordsNew.Enabled = True : tbNew.Enabled = True
                miRecordsDelete.Enabled = True : tbDelete.Enabled = True
                miViewLookup.Enabled = True : tbLookup.Enabled = True
                miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
                lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
            ElseIf Grid1.DataRowIndex = Grid1.Current.DataView.Count Then
                miViewSelect.Enabled = False
                miRecordsNext.Enabled = False : tbNext.Enabled = False
                If Grid1.Current.DataView.Count = 0 Then
                    miRecordsLast.Enabled = False : tbLast.Enabled = False
                Else
                    miRecordsLast.Enabled = True : tbLast.Enabled = True
                End If
                miRecordsGoTo.Enabled = True
                miRecordsNew.Enabled = False : tbNew.Enabled = False
                miRecordsDelete.Enabled = False : tbDelete.Enabled = False
                miViewLookup.Enabled = True : tbLookup.Enabled = True
                miViewDrilldown.Enabled = False : tbDrilldown.Enabled = False
                lblCount.Text = [of] & " " & Grid1.Current.DataView.Count + 1
            Else
                miViewSelect.Enabled = True
                miRecordsNext.Enabled = True : tbNext.Enabled = True
                miRecordsLast.Enabled = True : tbLast.Enabled = True
                miRecordsGoTo.Enabled = True
                miRecordsNew.Enabled = True : tbNew.Enabled = True
                miRecordsDelete.Enabled = True : tbDelete.Enabled = True
                miViewLookup.Enabled = True : tbLookup.Enabled = True
                miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
                lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
            End If
        End If
        rowChange = True
        updNumber.Text = CStr(Grid1.DataRowIndex + 1)
        rowChange = False
    End Sub
    Private Sub Grid1_RowDoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowDoubleClick
        If Grid1.DataRowIndex > Grid1.Current.DataView.Count - 1 Then Grid1.Editing()
        If Grid1.DataRowIndex <= Grid1.Current.DataView.Count - 1 Then
            Dim sel As Boolean
            If Not Grid1.Relation Is Nothing Then
                If Grid1.Relation.ParentTable Is Grid1.Current.Table Then
                    sel = True
                End If
            End If
            If Not Grid1.MultiSelect Is Nothing Then
                If Grid1.MultiSelect.DataTable Is Grid1.Current.Table Then
                    sel = True
                End If
            End If
            If sel Then
                Grid1_RowSelect(sender, e)
            Else
                If Grid1.Current.Table.ChildRelations.Count > 0 Then '+ Grid1.Current.Table.Partners.Count
                    Dim cur As Model10.Current
                    'If Grid1.Current.Table.ChildRelations.Count = 1 Then
                    Dim rel As Model10.Relation = Grid1.Current.Table.ChildRelations(0)
                    If Not rel.ChildTable Is Nothing Then
                        If Grid1.Updating Then
                            cur = New Model10.Current( _
                                rel.ChildTable, _
                                rel, _
                                Grid1.Current.RowData.CreateChildView(rel.DataRelation), _
                                Grid1.Current.RowData, _
                                Grid1.Current.ParaRow, _
                                Grid1.Current.DataView.Count, _
                                Grid1.DataRowIndex + 1)
                        End If
                    End If
                    rel = Nothing
                    'End If
                    'If Grid1.Current.Table.Partners.Count = 1 Then
                    '    Dim prt As Model10.Partner = Grid1.Current.Table.Partners(0)
                    '    If Not prt.NextTable Is Nothing Then
                    '        cur = New Model10.Current( _
                    '            prt.NextTable, _
                    '            Nothing, _
                    '            prt.Table.Presentation.DataViewManager.CreateDataView(prt.NextTable.DataTable), _
                    '            Nothing, _
                    '            Grid1.Current.RowData, _
                    '            1, 1)
                    '    End If
                    '    prt = Nothing
                    'End If
                    If Not cur Is Nothing Then Grid1_RowDrilldown(sender, New Model10.DrilldownEventArgs(cur))
                    cur = Nothing
                End If
            End If
        End If
    End Sub
    Private Sub Grid1_RowSelect(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowSelect
        miViewSelect.PerformClick()
    End Sub
    Private Sub Grid1_RowEdit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowEdit
        If Grid1.DataRowIndex = Grid1.Current.DataView.Count - 1 Then
            If Grid1.Current.Table.InsertCommand Is Nothing Then
                miRecordsNext.Enabled = False : tbNext.Enabled = False
            Else
                miRecordsNext.Enabled = True : tbNext.Enabled = True
            End If
            miRecordsLast.Enabled = False : tbLast.Enabled = False
            If Grid1.Current.RowData.IsNew Then
                miViewSelect.Enabled = False
                miRecordsDelete.Enabled = False : tbDelete.Enabled = False
                miViewDrilldown.Enabled = False : tbDrilldown.Enabled = False
            Else
                miViewSelect.Enabled = True
                miRecordsDelete.Enabled = True : tbDelete.Enabled = True
                miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
            End If
            lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
        Else
            miViewSelect.Enabled = True
            miRecordsNext.Enabled = True : tbNext.Enabled = True
            miRecordsLast.Enabled = True : tbLast.Enabled = True
            miRecordsDelete.Enabled = True : tbDelete.Enabled = True
            miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
            lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
        End If
        '------------------------------
        miRecordsEdit.Enabled = False
        miRecordsCancel.Enabled = True
        miRecordsUpdate.Enabled = True
    End Sub
    Private Sub Grid1_RowUpdate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowUpdate
        miViewSelect.Enabled = True
        miRecordsDelete.Enabled = True : tbDelete.Enabled = True
        miRecordsNew.Enabled = True : tbNew.Enabled = True
        miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
        '------------------------------
        miRecordsEdit.Enabled = True
        miRecordsCancel.Enabled = False
        miRecordsUpdate.Enabled = False
        SetNumber()
        If Not Grid1.Layouting Is Nothing Then Grid1.Layouting.Changed = True
        If Navigator1.Visible Then Navigator1.Fill()
    End Sub
    Private Sub Grid1_RowCancel(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowCancel
        If Grid1.DataRowIndex = Grid1.Current.DataView.Count - 1 Then
            miViewSelect.Enabled = True
            If Grid1.Current.Table.InsertCommand Is Nothing Then
                miRecordsNext.Enabled = False : tbNext.Enabled = False
            Else
                miRecordsNext.Enabled = True : tbNext.Enabled = True
            End If
            miRecordsLast.Enabled = False : tbLast.Enabled = False
            miRecordsDelete.Enabled = True : tbDelete.Enabled = True
            miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
            lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
        ElseIf Grid1.DataRowIndex = Grid1.Current.DataView.Count Then
            miViewSelect.Enabled = False
            miRecordsNext.Enabled = False : tbNext.Enabled = False
            If Grid1.Current.DataView.Count = 0 Then
                miRecordsLast.Enabled = False : tbLast.Enabled = False
            Else
                miRecordsLast.Enabled = True : tbLast.Enabled = True
            End If
            miRecordsDelete.Enabled = False : tbDelete.Enabled = False
            miViewDrilldown.Enabled = False : tbDrilldown.Enabled = False
            lblCount.Text = [of] & " " & Grid1.Current.DataView.Count + 1
        Else
            miViewSelect.Enabled = True
            miRecordsNext.Enabled = True : tbNext.Enabled = True
            miRecordsLast.Enabled = True : tbLast.Enabled = True
            miRecordsDelete.Enabled = True : tbDelete.Enabled = True
            miViewDrilldown.Enabled = True : tbDrilldown.Enabled = True
            lblCount.Text = [of] & " " & Grid1.Current.DataView.Count
        End If
        '------------------------------
        miRecordsEdit.Enabled = True
        miRecordsCancel.Enabled = False
        miRecordsUpdate.Enabled = False
    End Sub
    Private Sub Grid1_RowDelete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RowDelete
        miRecordsEdit.Enabled = True
        miRecordsCancel.Enabled = False
        miRecordsUpdate.Enabled = False
        SetNumber()
        If Not Grid1.Layouting Is Nothing Then Grid1.Layouting.Changed = True
    End Sub
    Private Sub Grid1_RowDrilldown(ByVal sender As Object, ByVal e As Model10.DrilldownEventArgs) Handles Grid1.RowDrilldown
        Application.DoEvents()
        Cursor.Current = Cursors.WaitCursor
        '----------------------------------
        Try
            Model10.[Global].FillChildData(Grid1.Current.Table, Grid1.Current.ParaRow, Grid1.Current.RowData, Grid1.Relation)
            Navigator1.Chain.Add(e.Current)
            Grid1.Current.MemberName = Grid1.MemberName 'Ready For Back
            Grid1.Current = e.Current
            miViewBack.Enabled = True : tbBack.Enabled = True
            Fill(Navigator1.Chain.Count = 1)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        '----------------------------------
        Cursor.Current = Cursors.Default
    End Sub
    Private Sub Grid1_RequestBack(ByVal sender As Object, ByVal e As System.EventArgs) Handles Grid1.RequestBack
        If Navigator1.Chain.Count > 1 Then miViewBack.PerformClick()
    End Sub

    Private Sub lblOf_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblCount.DoubleClick
        miRecordsGoTo.PerformClick()
    End Sub
    'Private Sub lblParent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    miViewBack.PerformClick()
    'End Sub
    'Private Sub lblParent_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    lblParent.Font = New Font(lblParent.Font, FontStyle.Underline)
    'End Sub
    'Private Sub lblParent_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    lblParent.Font = New Font(lblParent.Font, FontStyle.Regular)
    'End Sub

    Private Sub miFileClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFileClose.Click
        Me.Close()
    End Sub
    Private Sub miFileSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFileSave.Click
        If Grid1.Layouting Is Nothing Then
            If Grid1.Updating Then
                Application.DoEvents()
                Cursor.Current = Cursors.WaitCursor
                '----------------------------------
                Try
                    Grid1.Current.Table.Presentation.UpdateForward()
                Catch ex As Exception
                    Avand.DataError.ShowError(ex, MessageBoxIcon.Error)
                End Try
                '----------------------------------
                Cursor.Current = Cursors.Default
            End If
        Else
            Grid1.Current.Table.DataTable.AcceptChanges()
        End If
    End Sub
    Private Sub miFileSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFileSaveAs.Click
    End Sub
    Private Sub miFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFilePrint.Click
        Application.DoEvents()
        Cursor.Current = Cursors.WaitCursor
        '----------------------------------
        Try
            Dim frm As New Avand.Preview(Grid1.Current.Table.Size, Grid1.User, Grid1.Layouting, Navigator1.Chain, Grid1.Current, Grid1.Relation)
            frm.miFilePrint.PerformClick()
            frm.Close() : frm = Nothing
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        '----------------------------------
        Cursor.Current = Cursors.Default
    End Sub
    Private Sub miFilePrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFilePrintPreview.Click
        miRecordsCancel.PerformClick()

        'Application.DoEvents()
        Cursor.Current = Cursors.WaitCursor
        '----------------------------------
        Try
            Dim frm As New Avand.Preview(Grid1.Current.Table.Size, Grid1.User, Grid1.Layouting, Navigator1.Chain, Grid1.Current, Grid1.Relation)
            'frm.StartPosition = FormStartPosition.Manual
            'If Me.Location.Y = -23 Then
            '    frm.Size = Grid1.Current.Table.Size
            'Else
            '    frm.Location = Me.Location
            '    frm.Size = Me.Size
            'End If
            frm.ShowDialog()
            'switch = True
            'Me.Close()
            'switch = False
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        '----------------------------------
        Cursor.Current = Cursors.Default
    End Sub
    Private Sub miFileDatasheetView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFileDatasheetView.Click
    End Sub
    Private Sub miEditCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miEditCut.Click
        Grid1.Deleting()
    End Sub
    Private Sub miEditCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miEditCopy.Click
        Grid1.Copying()
    End Sub
    Private Sub miEditPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miEditPaste.Click
        Grid1.Pasting()
    End Sub
    Private Sub miEditSelectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles miEditSelectAll.Click
        Grid1.SelectAll()
    End Sub
    Private Sub miViewSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewSelect.Click
        If Me.Modal Then Grid1.Selecting()
    End Sub
    Private Sub miRecordsFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsFirst.Click
        Grid1.DataRowIndex = 0
    End Sub
    Private Sub miRecordsPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsPrevious.Click
        Grid1.DataRowIndex -= 1
    End Sub
    Private Sub miRecordsNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsNext.Click
        Grid1.DataRowIndex += 1
    End Sub
    Private Sub miRecordsLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsLast.Click
        Grid1.DataRowIndex = Grid1.Current.DataView.Count - 1
    End Sub
    Private Sub miRecordsGoTo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsGoTo.Click
        Dim str As String = InputBox(GetSystemResource("GoTo"), "", CStr(Grid1.DataRowIndex + 1))
        If str <> "" Then
            If IsNumeric(str) Then
                Dim i As Integer = CInt(str)
                If i < 1 Then i = 1
                Dim totalRowCount As Integer = Grid1.Current.DataView.Count - CInt(Not Grid1.Current.Table.InsertCommand Is Nothing)
                If i > totalRowCount Then i = totalRowCount
                Grid1.DataRowIndex = i - 1
            End If
        End If
    End Sub
    Private Sub miRecordsNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsNew.Click
        Grid1.DataRowIndex = Grid1.Current.DataView.Count
    End Sub
    Private Sub miRecordsEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsEdit.Click
        Grid1.Editing()
    End Sub
    Private Sub miRecordsUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsUpdate.Click
        Grid1.Updating()
    End Sub
    Private Sub miRecordsCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsCancel.Click
        If Grid1.DataRowIndex <= Grid1.Current.DataView.Count - 1 And Grid1.Current.DataView.Count > 0 Then
            Grid1.Canceling(Grid1.Current.RowData)
        End If
    End Sub
    Private Sub miRecordsDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miRecordsDelete.Click
        Grid1.Deleting()
    End Sub
    Private Sub miViewBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewBack.Click
        Back(Navigator1.Chain.Count - 2)
    End Sub
    Private Sub miViewLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miLookupEmpty.Click, ciLookupEmpty.Click
        Dim str As String = CType(sender, MenuItem).Text

        Dim rel As Model10.Relation
        For Each rel In Grid1.Current.Table.ParentRelations
            If rel.Name = str Then
                Grid1.Lookup(New Model10.LookupEventArgs(Grid1.DataRowIndex, Grid1.Current.DataView, rel, rel.ParentTable))
                Exit For
            End If
        Next : rel = Nothing
    End Sub
    Private Sub miViewDrilldown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miDrilldownEmpty.Click, ciDrilldownEmpty.Click
        Dim str As String = CType(sender, MenuItem).Text
        Dim cur As Model10.Current

        Dim rel As Model10.Relation
        For Each rel In Grid1.Current.Table.ChildRelations
            If rel.Name = str Then
                If Not rel.ChildTable Is Nothing Then
                    If Grid1.Updating Then
                        cur = New Model10.Current( _
                                   rel.ChildTable, _
                                   rel, _
                                   Grid1.Current.RowData.CreateChildView(rel.DataRelation), _
                                   Grid1.Current.RowData, _
                                   Grid1.Current.ParaRow, _
                                   Grid1.Current.DataView.Count, _
                                   Grid1.DataRowIndex + 1)
                    End If
                End If
                Exit For
            End If
        Next : rel = Nothing

        'Dim prt As Model10.Partner
        'For Each prt In Grid1.Current.Table.Partners
        '    If prt.Name = str Then
        '        If Not prt.NextTable Is Nothing Then
        '            cur = New Model10.Current( _
        '                prt.NextTable, _
        '                Nothing, _
        '                prt.Table.Presentation.DataViewManager.CreateDataView(prt.NextTable.DataTable), _
        '                Nothing, _
        '                Grid1.Current.RowData, _
        '                1, 1)
        '        End If
        '        Exit For
        '    End If
        'Next : rel = Nothing

        If Not cur Is Nothing Then Grid1_RowDrilldown(Me, New Model10.DrilldownEventArgs(cur))
        cur = Nothing
    End Sub
    Private Sub miViewComputes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ciComputesEmpty.Click, miComputesEmpty.Click
        If Grid1.Updating Then
            Dim str As String = CType(sender, MenuItem).Text

            Dim com As Model10.Compute, comp As Model10.Compute
            For Each com In Grid1.Current.Table.Computes
                If com.Name.Trim.ToLower = str.Trim.ToLower Then
                    comp = com
                    Exit For
                End If
            Next : com = Nothing

            If Not comp Is Nothing Then
                Dim dialogResult As DialogResult = dialogResult.OK
                If comp.PromptMessage.Trim <> "" Then
                    dialogResult = MessageBox.Show(Me, comp.PromptMessage.Trim, comp.Name, MessageBoxButtons.OKCancel)
                End If
                If dialogResult = dialogResult.OK Then
                    Application.DoEvents()
                    Cursor.Current = Cursors.WaitCursor
                    '----------------------------------
                    Try
                        Select Case comp.Action
                            Case Model10.ActionMode.View : ComputeView(comp, Grid1.Current.DataView)
                            Case Model10.ActionMode.Table : ComputeView(comp, Grid1.Current.Table.DataTable.DefaultView)
                            Case Model10.ActionMode.Record : ComputeRecord(comp)
                        End Select
                        Grid1.Fill()
                    Catch ex As Exception
                        MsgBox(ex.Message)
                    End Try
                    '----------------------------------
                    Cursor.Current = Cursors.Default
                End If
            End If
            comp = Nothing
        End If
    End Sub
    Private Sub miViewFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewFilter.Click
        If fFilter Is Nothing Then fFilter = New Avand.Expression(Model10.ExpressionType.Filter, Grid1.Current.Table)
        fFilter.ShowDialog(Me)
        If fFilter.Changed Then
            If Grid1.Current.DataRow Is Nothing Or Grid1.Current.Relation Is Nothing Then
                Grid1.Current.DataView = Grid1.Current.Table.Presentation.DataViewManager.CreateDataView(Grid1.Current.Table.DataTable)
            Else
                Grid1.Current.DataView = Grid1.Current.DataRow.CreateChildView(Grid1.Current.Relation.DataRelation)
            End If

            Application.DoEvents()
            Cursor.Current = Cursors.WaitCursor
            '----------------------------------
            Try
                Fill(True)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            '----------------------------------
            Cursor.Current = Cursors.Default
        End If
    End Sub
    Private Sub miViewSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewSort.Click
        If fSort Is Nothing Then fSort = New Avand.Expression(Model10.ExpressionType.Sort, Grid1.Current.Table)
        fSort.ShowDialog(Me)
        If fSort.Changed Then
            If Grid1.Current.Relation Is Nothing Or Grid1.Current.Relation Is Nothing Then
                Grid1.Current.DataView = Grid1.Current.Table.Presentation.DataViewManager.CreateDataView(Grid1.Current.Table.DataTable)
            Else
                Grid1.Current.DataView = Grid1.Current.DataRow.CreateChildView(Grid1.Current.Relation.DataRelation)
            End If

            Application.DoEvents()
            Cursor.Current = Cursors.WaitCursor
            '----------------------------------
            Try
                Fill(True)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            '----------------------------------
            Cursor.Current = Cursors.Default
        End If
    End Sub
    Private Sub miViewSimpleFilter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewSimpleFilter.Click
        If Not Grid1.Current.Table.Detail Is Nothing Then
            Dim foo As String
            Dim lbl As Model10.Label
            Static str As String '= Grid1.Current.Table.Presentation.DataViewManager.DataViewSettings(Grid1.Current.Table.DataTable).RowFilter
            If Grid1.MemberName.Trim <> "" Then
                Dim mem As Model10.Member
                For Each mem In Grid1.Current.Table.Detail.Members
                    If TypeOf mem Is Model10.Label Then
                        lbl = CType(mem, Model10.Label)
                        If lbl.Name = Grid1.MemberName Then
                            Dim col As DataColumn = Grid1.Current.Table.DataTable.Columns(lbl.DataField)
                            If Not col Is Nothing Then
                                str = InputBox("Filter by:", "Filter Dialog", str).Trim
                                If str = "" Then
                                    foo = ""
                                Else
                                    If col.DataType Is System.Type.GetType("System.String") Then
                                        foo = "[" & lbl.DataField.Trim & "] Like '*" & str & "*'"
                                    ElseIf col.DataType Is System.Type.GetType("System.DateTime") Then
                                        foo = "[" & lbl.DataField.Trim & "] = #" & str & "#"
                                    Else
                                        foo = "[" & lbl.DataField.Trim & "] = " & str & ""
                                    End If
                                End If
                            End If
                            Exit For
                        End If
                        lbl = Nothing
                    End If
                Next : mem = Nothing
            End If
            If foo = "" And lbl Is Nothing Then
                Dim col As DataColumn
                For Each col In Grid1.Current.Table.DataTable.Columns
                    If col.DataType Is System.Type.GetType("System.String") Then
                        str = InputBox("Filter by:", "Filter Dialog", str).Trim
                        If str = "" Then
                            foo = ""
                        Else
                            foo = "[" & col.ColumnName & "] Like '*" & str & "*'"
                        End If
                        Exit For
                    End If
                Next : col = Nothing
            End If
            'If foo <> "" Then
            Grid1.Current.Table.Presentation.DataViewManager.DataViewSettings(Grid1.Current.Table.DataTable).RowFilter = foo

            If Grid1.Current.Relation Is Nothing Then
                Grid1.Current.DataView = Grid1.Current.Table.Presentation.DataViewManager.CreateDataView(Grid1.Current.Table.DataTable)
            Else
                Grid1.Current.DataView = Grid1.Current.DataRow.CreateChildView(Grid1.Current.Relation.DataRelation)
            End If
            Grid1.Current.MemberName = Grid1.MemberName

            Application.DoEvents()
            Cursor.Current = Cursors.WaitCursor
            '----------------------------------
            Try
                Fill(True)
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
            '----------------------------------
            Cursor.Current = Cursors.Default
            'End If
        End If
    End Sub
    Private Sub miViewCustom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewCustom.Click
        'If fConnectionList Is Nothing Then
        '    fConnectionList = New Avand.ConnectionList(Grid1.Current.Table.Name, Grid1.Current.Table.Presentation.Connections)
        '    fConnectionList.Show()
        'Else
        '    If fConnectionList.Visible Then
        '        fConnectionList.BringToFront()
        '    Else
        '        fConnectionList = New Avand.ConnectionList(Grid1.Current.Table.Name, Grid1.Current.Table.Presentation.Connections)
        '        fConnectionList.Show()
        '    End If
        'End If
    End Sub
    Private Sub miViewRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miViewRefresh.Click
        miRecordsCancel.PerformClick()
        If Not Grid1.Layouting Is Nothing Then
            If Grid1.Current.DataRow Is Nothing Then
                Grid1.Current.DataView = Grid1.Current.Table.Presentation.DataViewManager.CreateDataView(Grid1.Current.Table.DataTable)
            Else
                Grid1.Current.DataView = Grid1.Current.DataRow.CreateChildView(Grid1.Current.Relation.DataRelation)
            End If
            Fill(Navigator1.Chain.Count = 1)
        ElseIf Not Grid1.MultiSelect Is Nothing Then
            Dim i As Integer
            For i = Navigator1.Chain.Count - 1 To 1 Step -1
                Navigator1.Chain.RemoveAt(i)
            Next
            Grid1.Current = CType(Navigator1.Chain(0), Model10.Current)

            Model10.[Global].ClearAll(Grid1.Current.Table.Presentation)
            Try
                Model10.[Global].FillData(Grid1.Current.Table, Grid1.Current.ParaRow, Nothing)
            Catch ex As Exception
            End Try

            Fill(Navigator1.Chain.Count = 1)
        Else
            Dim tbl As Model10.Table
            If Navigator1.Chain.Count = 0 Then
                tbl = Grid1.Current.Table
            Else
                tbl = CType(Navigator1.Chain(0), Model10.Current).Table
            End If

            Application.DoEvents()
            Cursor.Current = Cursors.WaitCursor
            '----------------------------------
            If Avand.[Global].SetParameters(tbl.SelectCommand, Me, Navigator1.Chain, Grid1.Current) = DialogResult.OK Then
                Fill(Navigator1.Chain.Count = 1)
            End If
            '----------------------------------
            Cursor.Current = Cursors.Default

            tbl = Nothing
        End If
    End Sub

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
        Select Case e.Button.ImageIndex
            Case 0 'Print
                miFilePrint.PerformClick()
            Case 1 'Print Preview
                miFilePrintPreview.PerformClick()
            Case 2 'Datasheet View
                miFileDatasheetView.PerformClick()
            Case 3 'Save
                miFileSave.PerformClick()
            Case 4 'Refresh
                miViewRefresh.PerformClick()
            Case 5 'Filter
                miViewFilter.PerformClick()
            Case 6 'Sort
                miViewSort.PerformClick()
            Case 7 'Computes
                If ContextMenu4.MenuItems.Count = 1 Then miComputesEmpty.PerformClick()
            Case 8 'Back
                miViewBack.PerformClick()
            Case 9 'Lookup
            Case 10 'Drilldown
        End Select
    End Sub
    Private Sub ToolBar2_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar2.ButtonClick
        Select Case e.Button.ImageIndex
            Case 11 'First
                miRecordsFirst.PerformClick()
            Case 12 'Previous
                miRecordsPrevious.PerformClick()
        End Select
    End Sub
    Private Sub ToolBar3_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar3.ButtonClick
        Select Case e.Button.ImageIndex
            Case 13 'Next
                miRecordsNext.PerformClick()
            Case 14 'Last
                miRecordsLast.PerformClick()
            Case 15 'New
                miRecordsNew.PerformClick()
            Case 16 'Delete
                Grid1.Deleting(True)   'miRecordsDelete.PerformClick()
        End Select
    End Sub

    Private Sub updNumber_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updNumber.ValueChanged
        If Not rowChange Then Grid1.DataRowIndex = CInt(updNumber.Value) - 1
    End Sub

    'Private Function Cancel() As Boolean
    '    If mIsEdit Then
    '        Select Case MsgBox("Save Changes?", MsgBoxStyle.YesNoCancel Or MsgBoxStyle.Exclamation, "Save Presentation")
    '            Case MsgBoxResult.Cancel
    '                Cancel = True
    '            Case MsgBoxResult.Yes
    '                miFileSave.PerformClick()
    '                If mIsEdit Then Cancel = True
    '        End Select
    '    End If
    'End Function
    'Private Sub SaveEnabled()
    '    Dim i As Integer
    '    Grid1.DataView.RowStateFilter = DataViewRowState.Added
    '    i += Grid1.DataView.Count
    '    Grid1.DataView.RowStateFilter = DataViewRowState.Deleted
    '    i += Grid1.DataView.Count
    '    Grid1.DataView.RowStateFilter = DataViewRowState.ModifiedOriginal
    '    i += Grid1.DataView.Count
    '    Grid1.DataView.RowStateFilter = DataViewRowState.CurrentRows
    '    miFileSave.Enabled = i <> 0
    '    tbSave.Enabled = miFileSave.Enabled
    'End Sub
    Private Sub Back(ByVal index As Integer)
        Application.DoEvents()
        Cursor.Current = Cursors.WaitCursor
        '----------------------------------
        If Grid1.Updating Then
            Dim i As Integer
            For i = Navigator1.Chain.Count - 1 To index + 1 Step -1
                Navigator1.Chain.RemoveAt(i)
            Next

            If Navigator1.Chain.Count > index Then
                Grid1.Current = CType(Navigator1.Chain(index), Model10.Current)
                Fill(Navigator1.Chain.Count = 1)
            End If
        End If
        '----------------------------------
        Cursor.Current = Cursors.Default
    End Sub
    Private Sub ComputeView(ByVal compute As Model10.Compute, ByVal dataView As DataView)
        Dim i As Integer, err As Boolean
        For i = dataView.Count - 1 To 0 Step -1
            Dim row As DataRowView = dataView(i)
            Dim foo As Boolean = False
            If compute.SelectionField Is Nothing Then
                foo = True
            Else
                Dim dField As String = compute.SelectionField.Trim
                If dField = "" Then
                    foo = True
                Else
                    Dim obj As Object = row(dField)
                    If TypeOf obj Is Boolean Then
                        If CBool(obj) Then foo = True
                    End If
                    obj = Nothing
                End If
            End If
            If foo Then
                ReadLabels(row, i)

                Dim prm As OleDb.OleDbParameter
                For Each prm In compute.OleDbCommand.Parameters
                    If prm.Direction = ParameterDirection.Input Or prm.Direction = ParameterDirection.InputOutput Then
                        If Not prm.SourceColumn Is Nothing Then
                            If row.DataView.Table.Columns.Contains(prm.SourceColumn) Then
                                prm.Value = row(prm.SourceColumn)
                            Else
                                If Not Grid1.Current.ParaRow Is Nothing Then
                                    If Grid1.Current.ParaRow.DataView.Table.Columns.Contains(prm.SourceColumn) Then
                                        prm.Value = Grid1.Current.ParaRow(prm.SourceColumn)
                                    End If
                                End If
                            End If
                        End If
                    End If
                Next : prm = Nothing

                If Not compute.Prepared Then
                    compute.OleDbCommand.Prepare()
                    compute.Prepared = True
                End If
                Try
                    compute.OleDbCommand.ExecuteNonQuery()
                    row.Row.AcceptChanges()
                    For Each prm In compute.OleDbCommand.Parameters
                        If prm.Direction = ParameterDirection.Output Or prm.Direction = ParameterDirection.InputOutput Then
                            If Grid1.Current.RowData.DataView.Table.Columns.Contains(prm.SourceColumn) Then
                                row(prm.SourceColumn) = prm.Value
                            End If
                        End If
                    Next : prm = Nothing
                    If compute.Remove Then
                        row.DataView.Table.Rows.Remove(row.Row)
                    Else
                        WriteMessage(row, "")
                    End If
                Catch ex As Exception
                    WriteMessage(row, ex.Message)
                    err = True
                End Try
            End If
            row = Nothing
        Next

        If err Then
            MsgBox("Some errors occurred!")
        Else
            MsgBox("Done!")
        End If
    End Sub
    Private Sub ComputeRecord(ByVal compute As Model10.Compute)
        Dim err As Boolean
        Dim row As DataRowView = Grid1.Current.RowData
        Dim foo As Boolean = False
        If compute.SelectionField Is Nothing Then
            foo = True
        Else
            Dim dField As String = compute.SelectionField.Trim
            If dField = "" Then
                foo = True
            Else
                Dim obj As Object = row(dField)
                If TypeOf obj Is Boolean Then
                    If CBool(obj) Then foo = True
                End If
                obj = Nothing
            End If
        End If
        If foo Then
            ReadLabels(row, Grid1.Current.RecordNumber - 1)

            Dim prm As OleDb.OleDbParameter
            For Each prm In compute.OleDbCommand.Parameters
                If prm.Direction = ParameterDirection.Input Or prm.Direction = ParameterDirection.InputOutput Then
                    If Not prm.SourceColumn Is Nothing Then
                        If row.DataView.Table.Columns.Contains(prm.SourceColumn) Then
                            prm.Value = row(prm.SourceColumn)
                        Else
                            If Not Grid1.Current.ParaRow Is Nothing Then
                                If Grid1.Current.ParaRow.DataView.Table.Columns.Contains(prm.SourceColumn) Then
                                    prm.Value = Grid1.Current.ParaRow(prm.SourceColumn)
                                End If
                            End If
                        End If
                    End If
                End If
            Next : prm = Nothing

            If Not compute.Prepared Then
                compute.OleDbCommand.Prepare()
                compute.Prepared = True
            End If
            Try
                compute.OleDbCommand.ExecuteNonQuery()
                row.Row.AcceptChanges()
                For Each prm In compute.OleDbCommand.Parameters
                    If prm.Direction = ParameterDirection.Output Or prm.Direction = ParameterDirection.InputOutput Then
                        If Grid1.Current.RowData.DataView.Table.Columns.Contains(prm.SourceColumn) Then
                            If Grid1.Current.RowData.DataView.Table.Columns(prm.SourceColumn).ReadOnly Then
                                Grid1.Current.RowData.DataView.Table.Columns(prm.SourceColumn).ReadOnly = False
                                row(prm.SourceColumn) = prm.Value
                                Grid1.Current.RowData.DataView.Table.Columns(prm.SourceColumn).ReadOnly = True
                            Else
                                row(prm.SourceColumn) = prm.Value
                            End If
                        End If
                    End If
                Next : prm = Nothing
                If compute.Remove Then
                    row.DataView.Table.Rows.Remove(row.Row)
                Else
                    WriteMessage(row, "")
                End If
            Catch ex As Exception
                WriteMessage(row, ex.Message)
                err = True
            End Try
        End If
        row = Nothing

        If err Then
            MsgBox("Some errors occurred!")
        Else
            MsgBox("Done!")
        End If
    End Sub
    Private Sub ReadLabels(ByVal row As DataRowView, ByVal rowIndex As Integer)
        Dim mem As Model10.Member
        For Each mem In Grid1.Current.Table.Detail.Members
            If TypeOf mem Is Model10.Label Then
                Dim lbl As New Model10.Label(CType(mem, Model10.Label))
                If lbl.DataField <> "" Then
                    Try
                        Select Case lbl.Value
                            Case Model10.ValueType.DateTime
                                row(lbl.DataField) = Date.Now
                            Case Model10.ValueType.Title
                                row(lbl.DataField) = Grid1.Current.Table.Presentation.Name
                            Case Model10.ValueType.Path
                                row(lbl.DataField) = Grid1.Current.Table.Presentation.Path
                            Case Model10.ValueType.PageCount
                            Case Model10.ValueType.PageNumber
                            Case Model10.ValueType.RecordCount
                                row(lbl.DataField) = Grid1.Current.DataView.Count
                            Case Model10.ValueType.RecordNumber
                                row(lbl.DataField) = rowIndex + 1
                            Case Model10.ValueType.UserId
                                row(lbl.DataField) = Grid1.User.Id
                            Case Model10.ValueType.UserFullName
                                row(lbl.DataField) = Grid1.User.FullName
                            Case Model10.ValueType.UserName
                                row(lbl.DataField) = Grid1.User.Name
                        End Select
                    Catch ex As Exception
                    End Try
                End If
                lbl = Nothing
            End If
        Next : mem = Nothing
    End Sub
    Private Sub EditMenu()
        If Grid1.TextMode Then
            miEditCut.Enabled = Grid1.SelectionLength > 0
            miEditCopy.Enabled = Grid1.SelectionLength > 0
            miEditPaste.Enabled = Clipboard.GetDataObject.GetDataPresent(GetType(String)) And Not Grid1.ReadOnly
            miEditSelectAll.Enabled = Grid1.Text.Length > 0 And Grid1.SelectionLength < Grid1.Text.Length
        Else
            If Grid1.DataRowIndex > Grid1.Current.DataView.Count - 1 Then
                miEditCut.Enabled = False
                miEditCopy.Enabled = False
                miEditPaste.Enabled = Not Grid1.Current.Table.InsertCommand Is Nothing And Not Grid1.PersistRow Is Nothing
            Else
                If Grid1.Current.RowData Is Nothing Then
                    miEditCut.Enabled = False
                    miEditCopy.Enabled = False
                    miEditPaste.Enabled = False
                Else
                    If Grid1.Current.RowData.IsNew Then
                        miEditCut.Enabled = False
                        miEditCopy.Enabled = True
                        miEditPaste.Enabled = True
                    Else
                        miEditCut.Enabled = Not Grid1.Current.Table.DeleteCommand Is Nothing
                        miEditCopy.Enabled = True
                        miEditPaste.Enabled = Not Grid1.Current.Table.UpdateCommand Is Nothing And Not Grid1.PersistRow Is Nothing
                    End If
                End If
            End If
            miEditSelectAll.Enabled = False
        End If
    End Sub
    Private Sub WriteMessage(ByVal row As DataRowView, ByVal text As String)
        Dim eField As String = Grid1.Current.Table.ErrorField.Trim
        If eField <> "" Then
            Try
                row(eField) = text
            Catch ex1 As Exception
            End Try
        End If
    End Sub
    Private Sub SetModal(Optional ByVal modal As Boolean = True)
        If modal Then
            Me.Menu = Nothing
            miViewSelect.Visible = True : miViewBar1.Visible = True
        Else
            Me.Menu = MainMenu1
            miViewSelect.Visible = False : miViewBar1.Visible = False
        End If
    End Sub
    Private Sub SetNumber()
        rowChange = True
        If Grid1.Current.Table.InsertCommand Is Nothing Then
            If Grid1.Current.DataView.Count = 0 Then
                updNumber.Maximum = 0
                updNumber.Minimum = 0
            Else
                updNumber.Maximum = Grid1.Current.DataView.Count
                updNumber.Minimum = 1
            End If
        Else
            If Grid1.Current.DataView.Count = 0 Then
                updNumber.Maximum = 1
                updNumber.Minimum = 1
            Else
                updNumber.Maximum = Grid1.Current.DataView.Count + 1
                updNumber.Minimum = 1
            End If
        End If
        rowChange = False
    End Sub

    Public Sub Fill(ByVal tree As Boolean, Optional ByVal simple As Boolean = False)
        If tree Then
            '-----------------Special
            'For Each rel As DataRelation In Grid1.Current.Table.DataTable.ChildRelations
            '    If rel.ChildTable Is Grid1.Current.Table.DataTable And rel.ParentTable Is Grid1.Current.Table.DataTable Then
            '        Grid1.Current.DataView.RowFilter = rel.ChildColumns(0).ColumnName + " IS NULL"
            '    End If
            'Next
            '-----------------Special
        End If

        If Not simple Then
            fFilter = Nothing
            fSort = Nothing
            Me.Text = GetSystemResource("FormView.Title") & " - " & Grid1.Current.Table.Presentation.Name & "\" & Grid1.Current.Table.Name
            Dim rtl As Windows.Forms.RightToLeft
            Select Case Grid1.Current.Table.Presentation.RightToLeft
                Case RightToLeft.No : rtl = RightToLeft.No
                Case RightToLeft.Yes : rtl = RightToLeft.Yes
                Case RightToLeft.Inherit : rtl = RightToLeft
            End Select
            Grid1.RightToLeft = rtl : Navigator1.RightToLeft = rtl
            [of] = GetSystemResource("Presentation.Of")
        End If

        SetNumber()
        Grid1.Fill(simple) : If Grid1.Current.Table.Navigator Then Navigator1.Fill()
        If Not Grid1.Current.RowData Is Nothing Then
            If Grid1.Current.RowData.IsEdit Then
                miRecordsEdit.Enabled = False
                miRecordsCancel.Enabled = True
                miRecordsUpdate.Enabled = True
            Else
                miRecordsEdit.Enabled = True
                miRecordsCancel.Enabled = False
                miRecordsUpdate.Enabled = False
            End If
        Else
            If Grid1.Current.DataView.Count = 0 Then
                miRecordsEdit.Enabled = False
                miRecordsCancel.Enabled = False
                miRecordsUpdate.Enabled = False
            Else
                miRecordsEdit.Enabled = True
                miRecordsCancel.Enabled = False
                miRecordsUpdate.Enabled = False
            End If
        End If

        If Not simple Then
            Dim i, j As Integer
            Dim com As Model10.Compute
            For Each com In Grid1.Current.Table.Computes
                If com.Action = Model10.ActionMode.View Or com.Action = Model10.ActionMode.Table Or com.Action = Model10.ActionMode.Record Then
                    If i > ContextMenu4.MenuItems.Count - 1 Then
                        ContextMenu4.MenuItems.Add(com.Name, AddressOf miViewComputes_Click)
                    Else
                        ContextMenu4.MenuItems(i).Text = com.Name
                    End If
                    If i > miViewComputes.MenuItems.Count - 1 Then
                        miViewComputes.MenuItems.Add(com.Name, AddressOf miViewComputes_Click)
                    Else
                        miViewComputes.MenuItems(i).Text = com.Name
                    End If
                    i += 1
                End If
            Next : com = Nothing
            If i = 0 Then
                i = 1
                miViewComputes.MenuItems(0).Text = GetSystemResource("Empty")
                miViewComputes.MenuItems(0).Enabled = False
                ContextMenu4.MenuItems(0).Text = GetSystemResource("Empty")
                ContextMenu4.MenuItems(0).Enabled = False
            Else
                miViewComputes.MenuItems(0).Enabled = True
                ContextMenu4.MenuItems(0).Enabled = True
            End If
            For j = ContextMenu4.MenuItems.Count - 1 To i Step -1
                RemoveHandler ContextMenu4.MenuItems(j).Click, AddressOf miViewComputes_Click
                ContextMenu4.MenuItems.RemoveAt(j)
            Next
            For j = miViewComputes.MenuItems.Count - 1 To i Step -1
                RemoveHandler miViewComputes.MenuItems(j).Click, AddressOf miViewComputes_Click
                miViewComputes.MenuItems.RemoveAt(j)
            Next
            '---------------------------------------
            If Navigator1.Chain.Count = 1 Or Not Grid1.Current.Table.Navigator Then
                Navigator1.Visible = False
                Splitter1.Visible = False
            Else
                Navigator1.Visible = True
                Splitter1.Visible = True

                Navigator1.BringToFront()
                Splitter1.BringToFront()
                Grid1.BringToFront()
            End If
            'If mChain.Count = 1 Then
            '    tvTables.Nodes.Clear()
            '    tvTables.Visible = False
            'Else
            '    tvTables.Height = 0
            '    tvTables.BeginUpdate()
            '    tvTables.Nodes.Clear()
            '    Dim nds As TreeNodeCollection = tvTables.Nodes

            '    Dim l As Integer
            '    For l = 1 To mChain.Count - 1
            '        Dim cur As Model10.Current = CType(mChain(l), Model10.Current)
            '        Dim txt As String = "" 'cur.Table.Name & ": "
            '        If cur.Table.DataField = "" Then
            '            txt &= GetSystemResource("RowNumber") & " " & cur.RecordNumber
            '        Else
            '            Try
            '                Dim obj As Object
            '                If Not cur.DataRow Is Nothing Then
            '                    obj = cur.DataRow.Row(cur.Table.DataField)
            '                ElseIf Not cur.ParaRow Is Nothing Then
            '                    obj = cur.ParaRow.Row(cur.Table.DataField)
            '                End If
            '                If IsDBNull(obj) Then
            '                    txt &= GetSystemResource("RowNumber") & " " & cur.RecordNumber
            '                Else
            '                    txt &= CStr(obj)
            '                End If
            '                obj = Nothing
            '            Catch ex As Exception
            '                txt &= GetSystemResource("RowNumber") & " " & cur.RecordNumber
            '            End Try
            '        End If

            '        Dim tn As New TreeNode(txt)
            '        tn.Tag = cur
            '        nds.Add(tn)
            '        nds = tn.Nodes
            '        If Not tn.Parent Is Nothing Then tn.Parent.Expand()
            '        tvTables.SelectedNode = tn
            '        tn = Nothing
            '        cur = Nothing

            '        tvTables.Height += tvTables.ItemHeight
            '    Next

            '    nds = Nothing
            '    tvTables.EndUpdate()
            '    tvTables.Visible = True : tvTables.BringToFront() : Grid1.BringToFront()
            'End If

            miRecordsNew.Visible = Not Grid1.Current.Table.InsertCommand Is Nothing
            If Grid1.Current.Table.UpdateCommand Is Nothing And Grid1.Current.Table.InsertCommand Is Nothing Then
                miRecordsEdit.Visible = False
                miRecordsUpdate.Visible = False
                miRecordsCancel.Visible = False
            Else
                miRecordsEdit.Visible = True
                miRecordsUpdate.Visible = True
                miRecordsCancel.Visible = True
            End If
            miRecordsDelete.Visible = Not Grid1.Current.Table.DeleteCommand Is Nothing
            If miRecordsEdit.Visible Or miRecordsUpdate.Visible Or miRecordsCancel.Visible Or miRecordsDelete.Visible Then
                miRecordsBar2.Visible = True
            Else
                miRecordsBar2.Visible = False
            End If

            tbNew.Visible = Not Grid1.Current.Table.InsertCommand Is Nothing
            tbDelete.Visible = Not Grid1.Current.Table.DeleteCommand Is Nothing
            tbSep7.Visible = tbNew.Visible Or tbDelete.Visible

            If Navigator1.Chain.Count = 1 Then
                miViewBack.Enabled = False : tbBack.Enabled = False
            Else
                miViewBack.Enabled = True : tbBack.Enabled = True
            End If

            For i = 0 To Grid1.Current.Table.ParentRelations.Count - 1
                Dim str As String = Grid1.Current.Table.ParentRelations(i).Name
                If i > miViewLookup.MenuItems.Count - 1 Then
                    miViewLookup.MenuItems.Add(str, AddressOf miViewLookup_Click)
                Else
                    miViewLookup.MenuItems(i).Text = str
                End If
                If i > ContextMenu2.MenuItems.Count - 1 Then
                    ContextMenu2.MenuItems.Add(str, AddressOf miViewLookup_Click)
                Else
                    ContextMenu2.MenuItems(i).Text = str
                End If
            Next
            If i = 0 Then
                i = 1
                miViewLookup.MenuItems(0).Text = GetSystemResource("Empty")
                miViewLookup.MenuItems(0).Enabled = False
                ContextMenu2.MenuItems(0).Text = GetSystemResource("Empty")
                ContextMenu2.MenuItems(0).Enabled = False
            Else
                miViewLookup.MenuItems(0).Enabled = True
                ContextMenu2.MenuItems(0).Enabled = True
            End If
            For j = miViewLookup.MenuItems.Count - 1 To i Step -1
                RemoveHandler miViewLookup.MenuItems(j).Click, AddressOf miViewLookup_Click
                miViewLookup.MenuItems.RemoveAt(j)
            Next
            For j = ContextMenu2.MenuItems.Count - 1 To i Step -1
                RemoveHandler ContextMenu2.MenuItems(j).Click, AddressOf miViewLookup_Click
                ContextMenu2.MenuItems.RemoveAt(j)
            Next
            For i = 0 To Grid1.Current.Table.ChildRelations.Count - 1
                Dim str As String = Grid1.Current.Table.ChildRelations(i).Name
                If i > miViewDrilldown.MenuItems.Count - 1 Then
                    miViewDrilldown.MenuItems.Add(str, AddressOf miViewDrilldown_Click)
                Else
                    miViewDrilldown.MenuItems(i).Text = str
                End If
                If i > ContextMenu3.MenuItems.Count - 1 Then
                    ContextMenu3.MenuItems.Add(str, AddressOf miViewDrilldown_Click)
                Else
                    ContextMenu3.MenuItems(i).Text = str
                End If
            Next
            'Dim k As Integer = i
            'For i = k To Grid1.Current.Table.Partners.Count - 1 + k
            '    Dim str As String = Grid1.Current.Table.Partners(i - k).Name
            '    If i > miViewDrilldown.MenuItems.Count - 1 Then
            '        miViewDrilldown.MenuItems.Add(str, AddressOf miViewDrilldown_Click)
            '    Else
            '        miViewDrilldown.MenuItems(i).Text = str
            '    End If
            '    If i > ContextMenu3.MenuItems.Count - 1 Then
            '        ContextMenu3.MenuItems.Add(str, AddressOf miViewDrilldown_Click)
            '    Else
            '        ContextMenu3.MenuItems(i).Text = str
            '    End If
            'Next
            If i = 0 Then
                i = 1
                miViewDrilldown.MenuItems(0).Text = GetSystemResource("Empty")
                miViewDrilldown.MenuItems(0).Enabled = False
                ContextMenu3.MenuItems(0).Text = GetSystemResource("Empty")
                ContextMenu3.MenuItems(0).Enabled = False
            Else
                miViewDrilldown.MenuItems(0).Enabled = True
                ContextMenu3.MenuItems(0).Enabled = True
            End If
            For j = miViewDrilldown.MenuItems.Count - 1 To i Step -1
                RemoveHandler miViewDrilldown.MenuItems(j).Click, AddressOf miViewDrilldown_Click
                miViewDrilldown.MenuItems.RemoveAt(j)
            Next
            For j = ContextMenu3.MenuItems.Count - 1 To i Step -1
                RemoveHandler ContextMenu3.MenuItems(j).Click, AddressOf miViewDrilldown_Click
                ContextMenu3.MenuItems.RemoveAt(j)
            Next
        End If
        Grid1.Select()
    End Sub
    Public Sub Refine()
        If Not Grid1.ParentFormView Is Nothing Then
            If Grid1.ParentFormView.Grid1.Current.RowData Is Nothing Then
                Me.Close()
            Else
                If Grid1.ParentFormView.Grid1.Current.RowData.Row.RowState = DataRowState.Detached _
                Or Grid1.ParentFormView.Grid1.Current.RowData.Row.RowState = DataRowState.Deleted Then
                    Me.Close()
                End If
            End If
            Grid1.ParentFormView.Refine()
        End If

        Dim r As Integer
        For r = 0 To Navigator1.Chain.Count - 1
            Dim cur As Model10.Current = CType(Navigator1.Chain(r), Model10.Current)
            If Not cur.DataRow Is Nothing Then
                If cur.DataRow.Row.RowState = DataRowState.Detached _
                Or cur.DataRow.Row.RowState = DataRowState.Deleted Then
                    Exit For
                End If
            End If
            cur = Nothing
        Next

        Dim j As Integer
        For j = Navigator1.Chain.Count - 1 To r Step -1
            Navigator1.Chain.RemoveAt(j)
        Next

        Grid1.Current = CType(Navigator1.Chain(Navigator1.Chain.Count - 1), Model10.Current)
        Fill(Navigator1.Chain.Count = 1)
    End Sub

    Public Sub New(ByVal size As Size, ByVal user As Model10.User, ByVal layout As Avand.Layout, ByVal chain As ArrayList, ByVal current As Model10.Current, ByVal relation As Model10.Relation, ByVal oledbConnection As OleDb.OleDbConnection, ByVal connections As Model10.ConnectionCollection)
        MyBase.New()
        InitializeComponent()

        'Me.MdiParent = fMain
        Me.Size = size
        Grid1.User = user
        Grid1.Layouting = layout
        Navigator1.Chain = chain
        Grid1.Current = current
        Grid1.Relation = relation
        Grid1.OleDbConnection = oledbConnection
        Grid1.Connections = connections

        Navigator1.Chain = chain
        Navigator1.User = user

        Fill(Navigator1.Chain.Count = 1)
    End Sub
End Class
